//
//  FZIntroduceCollectionViewCell.m
//  EnglishTalk
//
//  Created by CyonLeuPro on 15/8/24.
//  Copyright (c) 2015年 Feizhu Tech. All rights reserved.
//

#import "FZIntroduceCollectionViewCell.h"
#import "UIButton+FZGreenButton.h"
#import <UIDeviceUtil.h>
NSString *const kFZIntroduceCollectionViewCell = @"FZIntroduceCollectionViewCell";

@implementation FZIntroduceCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
//    self.entranceButton.titleLabel.font = [UIFont systemFontOfSize:19];
//    [self.entranceButton setTitleColor:[FZStyleSheet currentStyleSheet].color_1 forState:UIControlStateNormal];
//    self.entranceButton.backgroundColor=[FZStyleSheet currentStyleSheet].colorOfLighterText;
   // self.entranceButtonWidthConstraint.constant = P2PSZ(290);
    //self.entraceButtonBottomConstrait.constant = P2PSZ(170);
    
    //self.entranceButton.layer.cornerRadius=self.entranceButton.height/2;
    //self.entranceButton.clipsToBounds=YES;
    [self.entranceButton setImage:[UIImage  imageNamed:@"guide-page_button_entered"] forState:UIControlStateNormal];

    
//    FLUITapGestureRecognizer* tapGesture = [[FLUITapGestureRecognizer alloc] initWithTarget:self action:@selector(onEntranceButton:)];
//    self.goImageView.userInteractionEnabled = YES;
//    [self.goImageView addGestureRecognizer:tapGesture];
    
    [self.entranceButton addTarget:self action:@selector(onEntranceButton:) forControlEvents:UIControlEventTouchUpInside];
//    self.animationY.constant = 120;
    
    //self.animationImageView = [[UIImageView alloc] init];
    //[self addSubview:self.animationImageView];
    
    //[self resetAnimationImageFrame];
}

- (void)onEntranceButton:(UIButton *)sender {
    if (self.entranceButtonBlock) {
        self.entranceButtonBlock();
    }
}

- (void)resetAnimationImageFrame {
    CGFloat imageWidth = SCREEN_WIDTH;
    CGFloat imageHeight = 0;
//    if ([UIDeviceUtil hardware] == IPHONE_4 || [UIDeviceUtil hardware] == IPHONE_4S) {
//        imageHeight = imageWidth * (640 / 960);
//    } else {
        imageHeight = imageWidth * (516.0 / 750);
//    }
    if ([UIDeviceUtil hardware] == IPHONE_4 || [UIDeviceUtil hardware] == IPHONE_4S) {
        self.animationImageView.frame = CGRectMake(0, 100, imageWidth, imageHeight);
    } else {
        self.animationImageView.frame = CGRectMake(0, 120, imageWidth, imageHeight);
    }
}

- (void)showAnimation:(BOOL)animated {
    
    CGFloat imageWidth = SCREEN_WIDTH;
    CGFloat imageHeight = 0;

//        imageHeight = imageWidth * (640 / 960);
//    } else {
        imageHeight = imageWidth * (516.0 / 750);
//    }
        if ([UIDeviceUtil hardware] == IPHONE_4 || [UIDeviceUtil hardware] == IPHONE_4S) {
            self.animationImageView.frame = CGRectMake(0, 100, imageWidth, imageHeight);
        } else {
            self.animationImageView.frame = CGRectMake(0, 120, imageWidth, imageHeight);
        }
    
    [UIView animateWithDuration:1 animations:^{
        self.animationImageView.frame = CGRectMake(0, (SCREEN_HEIGHT - imageHeight) / 2 , imageWidth, imageHeight);
//
    } completion:^(BOOL finished) {
        if (finished) {
//            self.animationImageView.frame = CGRectMake(0, 200, imageWidth, imageHeight);
        }
    }];
}


@end
